// 云函数入口文件
const cloud = require('wx-server-sdk')
const mysql = require('mysql2/promise')
cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  try{
    const connection =await mysql.createConnection({
      host:"106.15.35.37",
      database:"wechat",
      user:"team",
      password:"MySQL@2021"
    })
    const results=await connection.execute('SELECT * FROM hatch')
    console.log(results[0])
    connection.destroy()
    return results[0]
  }catch(err){
    console.log("连接错误",err)
    return err
  }

}